<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>鼠标事件</title>
    <style>

        .box {
            width: 100px;
            height: 100px;
            background-color: greenyellow;
        }

    </style>
</head>
<body>

<div class="box" id="box">

    <span id="message"></span>

</div>
</body>
<script>
    var box = document.getElementById('box');
    box.onmouseover =function () {
        var messageSpan = document.getElementById('message');
        messageSpan.innerText = "鼠标移入了";
    }

    box.onmouseout=function () {
        var messageSpan = document.getElementById('message');
        messageSpan.innerText = "鼠标移出了";
    }


</script>
</html>